/*
    站点信息模块相关api
*/
var express = require("express");
var router = express.Router();
const parseUrl = require('url');
var queryString = require("querystring")

let site = require("../controller/site")

//获取访问者ip并进行存储
router.get('/getIP', (req, res) => {
    let ip = req.ip
    site.getIP(ip).then(data => {
        res.send('success')
    }).catch(err => {
        res.send(err)
    })
})

//统计某日访问量
router.get('/getVisitNumber', (req, res) => {
    let date = req.query.date;
    site.getVisitNumber(date).then(data => {
        res.send(data)
    })
})

//统计连续10日访问量
router.get('/getVNList', (req, res) => {
    let n = req.query.n - 1;
    site.getVisitNumberBetweenDate(n).then(data => {
        res.send(data)
    })
})

module.exports = router